package de.tabuma.pm.projectnavigation.controller;

import de.tabuma.pm.controller.*;
import de.tabuma.pm.projectnavigation.controller.create;
import de.tabuma.pm.project.entity.Project;
import de.tabuma.pm.projectnavigation.entity.ProjectNavigation;
import de.tabuma.pm.projectnavigation.entity.ProjectNavigationWrapper;
import de.tabuma.pm.projectnavigation.logik.ProjectNavigationFacade;
import de.tabuma.lib.tabumacontroller;
import de.tabuma.pm.*;
import java.io.PrintWriter;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.google.appengine.api.users.*;

/**
 *
 * @author alefen
 */
public class list extends tabumacontroller {

    private static Logger log = Logger.getLogger(list.class.getName());

    public list(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    @Override
    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {

        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();

        Project project = (Project) request.getAttribute(constants.paramProject);
        List<ProjectNavigation> pnList = ProjectNavigationFacade.getList(project.getId().intValue());
        
        ProjectNavigation pn = new ProjectNavigation();
        pn.setId(new Long(0));
        pn.setProjectId(project.getId().intValue());
        pn.setNavMode(0);
        
        ProjectNavigationWrapper pnw = new ProjectNavigationWrapper(pn, -1);
        pnw.loadSubElement(pnList);
        request.setAttribute(constants.ProjectNavigationWrapper,pnw);
        
        create cpnc = new create(this.getServlet(), this.getParameter());
        cpnc.navigate(context, request, response, out);
        
        update upnc = new update(this.getServlet(), this.getParameter());
        upnc.navigate(context, request, response, out);

        remove rpnc = new remove(this.getServlet(), this.getParameter());
        rpnc.navigate(context, request, response, out);
        
        pncontent pnc = new pncontent(this.getServlet(), this.getParameter());
        pnc.navigate(context, request, response, out);
        
    }

}
